﻿Public Class BlockSevenHomeworkSectionTwo
    Dim QuestionNumber As Integer
    Dim dtmTest, dtmTest2 As Date
    Dim filename As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    'Declare the Array as 10 rows and 3 columns
    Dim ArrayMax As Integer = 80 'One number past the end of actual info in array
    Dim HWQuestions(ArrayMax, 7) As String
    Dim intResponse As Integer
    Dim intQuestionCount As Integer = 0
    Dim intAnswerCount As Integer = 0
    Dim intReferenceCount As Integer = 0
    Dim intFirstRun As Integer = 1
    Dim strUser As String = "Enter Last Name"
    Dim strAnswer, strAnswer2, strAnswer3, strAnswer4, strAnswer5, _
     strAnswer6, strAnswer7, strAnswer8, strAnswer9, strAnswer10, strAnswer11, _
     strAnswer12, strAnswer13, strAnswer14, strAnswer15, strAnswer16, _
     strAnswer17, strAnswer18, strAnswer19, strAnswer20, strAnswer21, _
     strAnswer22, strAnswer23, strAnswer24, strAnswer25, strAnswer26, _
     strAnswer27, strAnswer28, strAnswer29, strAnswer30, strAnswer31, _
     strAnswer32, strAnswer33, strAnswer34, strAnswer35, strAnswer36, _
     strAnswer37, strAnswer38, strAnswer39, strAnswer40, strAnswer41, _
     strAnswer42, strAnswer43, strAnswer44, strAnswer45, strAnswer46, _
     strAnswer47, strAnswer48, strAnswer49, strAnswer50, strAnswer51, _
     strAnswer52, strAnswer53, strAnswer54, strAnswer55, strAnswer56, _
     strAnswer57, strAnswer58, strAnswer59, strAnswer60, strAnswer61, _
     strAnswer62, strAnswer63, strAnswer64, strAnswer65, strAnswer66, _
     strAnswer67, strAnswer68, strAnswer69, strAnswer70, strAnswer71, strAnswer72, _
     strAnswer73, strAnswer74, strAnswer75, strAnswer76, strAnswer77, _
     strAnswer78, strAnswer79 As String
    Dim intChoiceACount As Integer = 2
    Dim intChoiceBCount As Integer = 3
    Dim intChoiceCCount As Integer = 4
    Dim intChoiceDCount As Integer = 5

    Shared Property MidiParent As MainForm

    Private Sub CloseToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles CloseToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub BlockTwoHomeworkSectionOne_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtObj.Text = "Objectives:" + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the Localizer Antenna System." _
            + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the Localizer RF Detector Unit." _
             + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the Localizer Course Monitor." _
            + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the Localizer Course Monitor." _
            + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the Localizer Clearance Monitors." _
            + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the Glideslope RF Monitor Combining Units." _
            + vbCrLf + "- Given proper student instructional materials, identify the operating principles of the Glideslope Monitors."
        If (System.IO.File.Exists(filename & "\Homework\Block 7\Block 7 Section 2.txt")) Then
            intResponse = MsgBox("This assignment has already been completed.  Are you sure you want to delete the current assignment and reaccomplish it?", 4, "Confirm Assignment Deletion")
            If intResponse = MsgBoxResult.Yes Then
                System.IO.File.Delete(filename & "\Homework\Block 7\Block 7 Section 2.txt")
                System.IO.File.Create(filename & "\Homework\Block 7\Block 7 Section 2.txt").Dispose()
            ElseIf intResponse = MsgBoxResult.No Then
                Me.Close()
            End If
        End If
        If (Not System.IO.File.Exists(filename & "\Homework\Block 7\Block 7 Section 2.txt")) Then
            System.IO.File.Create(filename & "\Homework\Block 7\Block 7 Section 2.txt").Dispose()
        End If
        If (Not System.IO.File.Exists(filename & "\Instructor\Block 7\Block 7 Section 2.txt")) Then
            System.IO.File.Create(filename & "\Instructor\Block 7\Block 7 Section 2.txt").Dispose()
        End If
        strUser = InputBox("Please enter last name", strUser)
        If strUser Is "" Then
            Me.Close()
        End If
        '************************************************
        '****** Questions Are Loaded Here****************
        '******* Column 1 is Questions (Preloaded)*******
        '******* Column 2 is Accepts Students Answer*****
        '******* Column 3 is Reference ******************

        HWQuestions(1, 1) = ""
        HWQuestions(1, 2) = ""
        HWQuestions(1, 3) = ""

        HWQuestions(2, 1) = ""
        HWQuestions(2, 2) = ""
        HWQuestions(2, 3) = ""

        HWQuestions(3, 1) = ""
        HWQuestions(3, 2) = ""
        HWQuestions(3, 3) = ""

        HWQuestions(4, 1) = ""
        HWQuestions(4, 2) = ""
        HWQuestions(4, 3) = ""

        HWQuestions(5, 1) = ""
        HWQuestions(5, 2) = ""
        HWQuestions(5, 3) = ""

        HWQuestions(6, 1) = ""
        HWQuestions(6, 2) = ""
        HWQuestions(6, 3) = ""

        HWQuestions(7, 1) = ""
        HWQuestions(7, 2) = ""
        HWQuestions(7, 3) = ""

        'RF Detector Unit (unit 30)
        HWQuestions(8, 1) = ""
        HWQuestions(8, 2) = ""
        HWQuestions(8, 3) = ""

        HWQuestions(9, 1) = ""
        HWQuestions(9, 2) = ""
        HWQuestions(9, 3) = ""

        HWQuestions(10, 1) = ""
        HWQuestions(10, 2) = ""
        HWQuestions(10, 3) = ""

        HWQuestions(11, 1) = ""
        HWQuestions(11, 2) = ""
        HWQuestions(11, 3) = ""

        HWQuestions(12, 1) = ""
        HWQuestions(12, 2) = ""
        HWQuestions(12, 3) = ""

        'Block Diagram
        HWQuestions(13, 1) = ""
        HWQuestions(13, 2) = ""
        HWQuestions(13, 3) = ""

        HWQuestions(14, 1) = ""
        HWQuestions(14, 2) = ""
        HWQuestions(14, 3) = ""

        HWQuestions(15, 1) = ""
        HWQuestions(15, 2) = ""
        HWQuestions(15, 3) = ""

        HWQuestions(16, 1) = ""
        HWQuestions(16, 2) = ""
        HWQuestions(16, 3) = ""

        HWQuestions(17, 1) = ""
        HWQuestions(17, 2) = ""
        HWQuestions(17, 3) = ""

        HWQuestions(18, 1) = ""
        HWQuestions(18, 2) = ""
        HWQuestions(18, 3) = ""

        HWQuestions(19, 1) = ""
        HWQuestions(19, 2) = ""
        HWQuestions(19, 3) = ""

        HWQuestions(20, 1) = ""
        HWQuestions(20, 2) = ""
        HWQuestions(20, 3) = ""

        HWQuestions(21, 1) = ""
        HWQuestions(21, 2) = ""
        HWQuestions(21, 3) = ""

        HWQuestions(22, 1) = ""
        HWQuestions(22, 2) = ""
        HWQuestions(22, 3) = ""

        'Signal Processor A1 / A2
        HWQuestions(23, 1) = ""
        HWQuestions(23, 2) = ""
        HWQuestions(23, 3) = ""

        HWQuestions(24, 1) = ""
        HWQuestions(24, 2) = ""
        HWQuestions(24, 3) = ""

        HWQuestions(25, 1) = ""
        HWQuestions(25, 2) = ""
        HWQuestions(25, 3) = ""

        HWQuestions(26, 1) = ""
        HWQuestions(26, 2) = ""
        HWQuestions(26, 3) = ""

        'Timing Assembly A4
        HWQuestions(27, 1) = ""
        HWQuestions(27, 2) = ""
        HWQuestions(27, 3) = ""

        HWQuestions(28, 1) = ""
        HWQuestions(28, 2) = ""
        HWQuestions(28, 3) = ""

        HWQuestions(29, 1) = ""
        HWQuestions(29, 2) = ""
        HWQuestions(29, 3) = ""

        HWQuestions(30, 1) = ""
        HWQuestions(30, 2) = ""
        HWQuestions(30, 3) = ""

        'Cable Fault Assembly (A8)
        HWQuestions(31, 1) = ""
        HWQuestions(31, 2) = ""
        HWQuestions(31, 3) = ""

        HWQuestions(32, 1) = ""
        HWQuestions(32, 2) = ""
        HWQuestions(32, 3) = ""

        'Measurement(Assembly(A5))
        HWQuestions(33, 1) = ""
        HWQuestions(33, 2) = ""
        HWQuestions(33, 3) = ""

        HWQuestions(34, 1) = ""
        HWQuestions(34, 2) = ""
        HWQuestions(34, 3) = ""

        HWQuestions(35, 1) = ""
        HWQuestions(35, 2) = ""
        HWQuestions(35, 3) = ""

        HWQuestions(36, 1) = ""
        HWQuestions(36, 2) = ""
        HWQuestions(36, 3) = ""

        HWQuestions(37, 1) = ""
        HWQuestions(37, 2) = ""
        HWQuestions(37, 3) = ""

        HWQuestions(38, 1) = ""
        HWQuestions(38, 2) = ""
        HWQuestions(38, 3) = ""

        HWQuestions(39, 1) = ""
        HWQuestions(39, 2) = ""
        HWQuestions(39, 3) = ""

        HWQuestions(40, 1) = ""
        HWQuestions(40, 2) = ""
        HWQuestions(40, 3) = ""

        HWQuestions(41, 1) = ""
        HWQuestions(41, 2) = ""
        HWQuestions(41, 3) = ""

        HWQuestions(42, 1) = ""
        HWQuestions(42, 2) = ""
        HWQuestions(42, 3) = ""

        HWQuestions(43, 1) = ""
        HWQuestions(43, 2) = ""
        HWQuestions(43, 3) = ""

        HWQuestions(44, 1) = ""
        HWQuestions(44, 2) = ""
        HWQuestions(44, 3) = ""

        HWQuestions(45, 1) = ""
        HWQuestions(45, 2) = ""
        HWQuestions(45, 3) = ""

        HWQuestions(46, 1) = ""
        HWQuestions(46, 2) = ""
        HWQuestions(46, 3) = ""

        'Alarm(Assemblies(A6))
        HWQuestions(47, 1) = ""
        HWQuestions(47, 2) = ""
        HWQuestions(47, 3) = ""

        HWQuestions(48, 1) = ""
        HWQuestions(48, 2) = ""
        HWQuestions(48, 3) = ""

        HWQuestions(49, 1) = ""
        HWQuestions(49, 2) = ""
        HWQuestions(49, 3) = ""

        HWQuestions(50, 1) = ""
        HWQuestions(50, 2) = ""
        HWQuestions(50, 3) = ""

        HWQuestions(51, 1) = ""
        HWQuestions(51, 2) = ""
        HWQuestions(51, 3) = ""

        HWQuestions(52, 1) = ""
        HWQuestions(52, 2) = ""
        HWQuestions(52, 3) = ""

        HWQuestions(53, 1) = ""
        HWQuestions(53, 2) = ""
        HWQuestions(53, 3) = ""

        HWQuestions(54, 1) = ""
        HWQuestions(54, 2) = ""
        HWQuestions(54, 3) = ""

        HWQuestions(55, 1) = ""
        HWQuestions(55, 2) = ""
        HWQuestions(55, 3) = ""

        'Digital Readout Assembly (A7)
        HWQuestions(56, 1) = ""
        HWQuestions(56, 2) = ""
        HWQuestions(56, 3) = ""

        HWQuestions(57, 1) = ""
        HWQuestions(57, 2) = ""
        HWQuestions(57, 3) = ""

        HWQuestions(58, 1) = ""
        HWQuestions(58, 2) = ""
        HWQuestions(58, 3) = ""

        HWQuestions(59, 1) = ""
        HWQuestions(59, 2) = ""
        HWQuestions(59, 3) = ""

        HWQuestions(60, 1) = ""
        HWQuestions(60, 2) = ""
        HWQuestions(60, 3) = ""

        'Localizer Clearance Monitor (Unit 9)
        HWQuestions(61, 1) = ""
        HWQuestions(61, 2) = ""
        HWQuestions(61, 3) = ""

        HWQuestions(62, 1) = ""
        HWQuestions(62, 2) = ""
        HWQuestions(62, 3) = ""

        HWQuestions(63, 1) = ""
        HWQuestions(63, 2) = ""
        HWQuestions(63, 3) = ""

        'Localizer Clearance Assembly (A8)
        HWQuestions(64, 1) = ""
        HWQuestions(64, 2) = ""
        HWQuestions(64, 3) = ""

        HWQuestions(65, 1) = ""
        HWQuestions(65, 2) = ""
        HWQuestions(65, 3) = ""

        HWQuestions(66, 1) = ""
        HWQuestions(66, 2) = ""
        HWQuestions(66, 3) = ""

        HWQuestions(67, 1) = ""
        HWQuestions(67, 2) = ""
        HWQuestions(67, 3) = ""

        'Glide Slope RF Combing Unit
        HWQuestions(68, 1) = ""
        HWQuestions(68, 2) = ""
        HWQuestions(68, 3) = ""

        HWQuestions(69, 1) = ""
        HWQuestions(69, 2) = ""
        HWQuestions(69, 3) = ""

        HWQuestions(70, 1) = ""
        HWQuestions(70, 2) = ""
        HWQuestions(70, 3) = ""

        'Glide Slope RF Monitor
        HWQuestions(71, 1) = ""
        HWQuestions(71, 2) = ""
        HWQuestions(71, 3) = ""

        HWQuestions(72, 1) = ""
        HWQuestions(72, 2) = ""
        HWQuestions(72, 3) = ""

        HWQuestions(73, 1) = ""
        HWQuestions(73, 2) = ""
        HWQuestions(73, 3) = ""

        HWQuestions(74, 1) = ""
        HWQuestions(74, 2) = ""
        HWQuestions(74, 3) = ""

        HWQuestions(75, 1) = ""
        HWQuestions(75, 2) = ""
        HWQuestions(75, 3) = ""

        HWQuestions(76, 1) = ""
        HWQuestions(76, 2) = ""
        HWQuestions(76, 3) = ""

        HWQuestions(77, 1) = ""
        HWQuestions(77, 2) = ""
        HWQuestions(77, 3) = ""

        'Glide Slope Clearance Assembly (A8)
        HWQuestions(78, 1) = ""
        HWQuestions(78, 2) = ""
        HWQuestions(78, 3) = ""

        HWQuestions(79, 1) = ""
        HWQuestions(79, 2) = ""
        HWQuestions(79, 3) = ""

        HWQuestions(80, 1) = ""

        Next_Question(HWQuestions)
    End Sub

    Private Sub btnNextQuestion_Click(sender As System.Object, e As System.EventArgs) Handles btnNextQuestion.Click
        Next_Question(HWQuestions)
    End Sub
    Private Sub Clear_Display()
        txtQuestion.Clear()
        txtAnswer.Clear()
    End Sub

    Public Function Next_Question(HWQuestions As String(,))
        txtAnswer.Focus()
        If intQuestionCount > 0 Then
            WriteToFile()
        End If
        If btnNextQuestion.Text = "Done" Then
            Me.Close()
            OpenResults()
        End If
        intQuestionCount = intQuestionCount + 1
        LabelChangeCheck()
        If intQuestionCount = 79 Then
            btnNextQuestion.Text = "Done"
        End If
        txtQuestion.Text = HWQuestions(intQuestionCount, 1)
        intAnswerCount = intAnswerCount + 1
        HWQuestions(intAnswerCount, 2) = txtAnswer.Text
        intReferenceCount = intReferenceCount + 1
        txtReference.Text = HWQuestions(intReferenceCount, 3)

        Return intQuestionCount & intAnswerCount
    End Function

    Private Sub LabelChangeCheck()
        If intQuestionCount = 1 Then
            lblSubject.Text = "RDU"
        ElseIf intQuestionCount = 8 Then
            lblSubject.Text = "RF Detector Unit (unit 30)"
        ElseIf intQuestionCount = 13 Then
            lblSubject.Text = "Block Diagram"
        ElseIf intQuestionCount = 23 Then
            lblSubject.Text = "Signal Processor (A1/A2)"
        ElseIf intQuestionCount = 27 Then
            lblSubject.Text = "Timing Assembly (A4)"
        ElseIf intQuestionCount = 31 Then
            lblSubject.Text = "Cable Fault Assembly (A8)"
        ElseIf intQuestionCount = 33 Then
            lblSubject.Text = "Measurement Assembly (A5)"
        ElseIf intQuestionCount = 47 Then
            lblSubject.Text = "Alarm Assemblies (A6)"
        ElseIf intQuestionCount = 56 Then
            lblSubject.Text = "Digital Readout Assembly (A7)"
        ElseIf intQuestionCount = 61 Then
            lblSubject.Text = "Localizer Clearance Monitor (Unit 9)"
        ElseIf intQuestionCount = 63 Then
            lblSubject.Text = "Localizer Clearance Assembly (A8)"
        ElseIf intQuestionCount = 68 Then
            lblSubject.Text = "Glide Slope RF Combing Unit"
        ElseIf intQuestionCount = 71 Then
            lblSubject.Text = "Glide Slope RF Monitor"
        ElseIf intQuestionCount = 78 Then
            lblSubject.Text = "Glide Slope Clearance Assembly (A8)"
        End If
    End Sub

    Private Sub WriteToFile()
        Dim Integrity As String = (filename & "\Instructor\Block 7\Block 7 Section 2.txt")
        Dim Results As String = (filename & "\Homework\Block 7\Block 7 Section 2.txt")

        '***********Output to hidden file for Instructor Check***********
        If System.IO.File.Exists(Integrity) = True Then
            Dim hiddenWriter As New System.IO.StreamWriter(Integrity, True)
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine("- " & txtObj.Text)
                hiddenWriter.WriteLine()
                hiddenWriter.WriteLine("Student: " & strUser)
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
            hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
            hiddenWriter.WriteLine("Reference: " & txtReference.Text)
            hiddenWriter.WriteLine()
            If intQuestionCount = 79 Then
                hiddenWriter.WriteLine("Block 7 Section 2 Homework Complete")
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.Close()

            'MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist Integrity")
        End If

        '******Output to file for Student to review***********
        If System.IO.File.Exists(Results) = True Then
            Dim hiddenWriter As New System.IO.StreamWriter(Results, True)
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine("- " & txtObj.Text)
                hiddenWriter.WriteLine()
                hiddenWriter.WriteLine("Student: " & strUser)
                'hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                'hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
            hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
            'hiddenWriter.WriteLine("Reference: " & txtReference.Text)
            hiddenWriter.WriteLine()
            If intQuestionCount = 79 Then
                hiddenWriter.WriteLine("Block 7 Section 2 Homework Complete")
                'hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                'hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.Close()

            'MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist Results")
        End If

        If intQuestionCount > 0 Then
            txtAnswer.Clear()
        End If

    End Sub

    Private Sub OpenResults()
        Dim p As Process = Process.Start(filename & "\Homework\Block 7\Block 7 Section 2.txt")
    End Sub
End Class
